﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TugasAkhir.Helpers
{
    public class Skor
    {
        private int jumlahPopulasi;
        private int jumlahPertanyaan;
        private int skorMaks;
        private int[,] data;

        public Skor(int jumlahPopulasi, int jumlahPertanyaan, int[,] data, int skorMaks)
        {
            this.jumlahPopulasi = jumlahPopulasi;
            this.jumlahPertanyaan = jumlahPertanyaan;
            this.skorMaks = skorMaks;

            this.data = data;
        }

        public List<double> HitungSkor()
        {
            var result = new List<double>();

            for (int i = 0; i < this.jumlahPertanyaan; i++)
            {
                double temp = 0.0;
                for (int j = 0; j < this.jumlahPopulasi; j++)
                {
                    temp += (double)data[j, i];
                }

                double hasil = (temp / ((double)jumlahPopulasi * (double)skorMaks)) * 100.0;

                result.Add(hasil);
            }

            return result;
        }
    }
}